﻿using System.Net.Http;
using AutoMapper;
using Sanelib.CodeMaker;
using Sanelib.CodeMaker.Generators;
using Sanelib.Dto;
using WebApp.Services;

namespace WebApp.ControllerApis
{
    public class GeneratorController : SmartApiController
    {
        public GeneratorController(IUserSession userSession, IMappingEngine mappingEngine) : base(userSession, mappingEngine)
        {

        }

        public HttpResponseMessage Post(DatabaseTableSchema form)
        {
            var response = new WebApiResultResponse();
            var generator = new Generator();
            generator.AppendNewEntity(form);
            return Content(response.IsSuccess = true);
        }

        public HttpResponseMessage Delete(string id)
        {
            var response = new WebApiResultResponse();
            var generator = new Generator();
            generator.RemoveEntity(id);
            return Content(response.IsSuccess = true);
        }
    }
}
